Imports System.Windows.Forms
Imports System.Data.OracleClient

Public Class digSelectColumn

  Public mStrColumnName As String = String.Empty
  Public mObjRtn As New clsMemberProperties

  Public mBlnIsLoaded As Boolean = False
  Private mObjCommand As OracleCommand
  Private mObjDataReader As OracleDataReader
  Private mArrAbbreviationList As New ArrayList

  Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click


    Me.DialogResult = System.Windows.Forms.DialogResult.OK
    Me.Close()
  End Sub

  Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
    Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
    Me.Close()
  End Sub

  Private Sub digSelectColumn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim lStrQuery As String = String.Empty
    Dim lObjClsListBoxProperties As clsMemberProperties

    mPrRefreshConn()
    If mBlnIsLoaded = False Then
      lStrQuery = "Select Distinct TAV_CLMN_DSCRPTN, TAV_SERIAL_NMBR, TAV_DATA_CTGRY, TDCM_DESC"
      lStrQuery = lStrQuery + " from TRDX_DATA_CATEGORY_MSTR,TRDX_APLCTN_VRBLS where TAV_DATA_CTGRY = TDCM_DATA_CTGRY ORDER BY TAV_CLMN_DSCRPTN ASC"

      mObjCommand = New OracleCommand(lStrQuery, con)
      mObjDataReader = mObjCommand.ExecuteReader

      While mObjDataReader.Read
        lObjClsListBoxProperties = New clsMemberProperties
        lObjClsListBoxProperties.mPrpDisplayMember = UCase(mObjDataReader("TAV_CLMN_DSCRPTN"))
        lObjClsListBoxProperties.mPrpValueMember = UCase(mObjDataReader("TAV_SERIAL_NMBR"))
        lObjClsListBoxProperties.mPrpDataCatg = UCase(mObjDataReader("TDCM_DESC"))
        mArrAbbreviationList.Add(lObjClsListBoxProperties)
      End While

      For lIntCount As Integer = 0 To mArrAbbreviationList.Count - 1
        lstColmuns.Items.Add(mArrAbbreviationList.Item(lIntCount))
      Next

      lstColmuns.DisplayMember = "mPrpDisplayMember"
      lstColmuns.ValueMember = "mPrpValueMember"


      mBlnIsLoaded = True

      lstColmuns.Focus()
      lstColmuns.Text = mStrColumnName
      If lstColmuns.SelectedIndex = -1 And mStrColumnName <> "" Then MsgBox("This colmun was not in list", MsgBoxStyle.Information, gCONST_MSG_HEADER)
      lstColmuns.TopIndex = lstColmuns.SelectedIndex

    End If

  End Sub

  Private Sub lstColmuns_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstColmuns.SelectedIndexChanged
    mObjRtn = lstColmuns.SelectedItem
  End Sub

  Private Sub lstColmuns_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstColmuns.MouseDoubleClick
    mObjRtn = lstColmuns.SelectedItem
    Me.DialogResult = System.Windows.Forms.DialogResult.OK
    Me.Close()
  End Sub
End Class
